//
//  BaseTableViewCell.swift
//  Emergency_Swift
//
//  Created by 王宗成 on 2019/5/16.
//  Copyright © 2019 王宗成. All rights reserved.
//

import UIKit

class WZC_TableViewCell: UITableViewCell {
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    //标题
    lazy var titleLable: UILabel = {
        
        let InnerTitleLable = UILabel(frame: CGRect.init(x: 0, y: 0, width: 10, height: 20))
        self.contentView.addSubview(InnerTitleLable)
        InnerTitleLable.snp.makeConstraints({ (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(self.iconImgView.snp_right).offset(5)
        })
        return InnerTitleLable
    }()
    
    //自标题
    lazy var subTitleLable: UILabel = {
        
        let InnerTitleLable = UILabel(frame: CGRect.init(x: 0, y: 0, width: 10, height: 20))
        self.contentView.addSubview(InnerTitleLable)
        return InnerTitleLable
    }()
    //其他附加
    lazy var itemLable: UILabel = {
        
        let InnerTitleLable = UILabel(frame: CGRect.init(x: 0, y: 0, width: 10, height: 20))
        self.contentView.addSubview(InnerTitleLable)
        return InnerTitleLable
    }()
    //按钮
    lazy var commonBtn1: UIButton = {
        
        let button = UIButton()
        self.contentView.addSubview(button)
        return button
    }()
    //按钮
    lazy var commonBtn2: UIButton = {
        
        let button = UIButton()
        self.contentView.addSubview(button)
        return button
    }()
    
    //按钮
    lazy var commonBtn3: UIButton = {
        
        let button = UIButton()
        self.contentView.addSubview(button)
        return button
    }()
    
    //顶部分割线
    lazy var topLine: UIView = {
        
        let line = UIView()
        line.backgroundColor = UIColor.hexColor(hexadecimal: kCellSeparatorColor)
        self.contentView.addSubview(line)
        line.snp.makeConstraints { (make) in
            
            make.left.right.top.equalToSuperview()
            make.height.equalTo(1)
            
        }
        return line
    }()
    //底部分割线
    lazy var bottomLine: UIView = {
        
        let line = UIView()
        line.backgroundColor = UIColor.hexColor(hexadecimal: kCellSeparatorColor)
        self.contentView.addSubview(line)
        line.snp.makeConstraints { (make) in
            
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(1)
            
        }
        return line
    }()
    
    //知道箭头
    lazy var arrowImgView: UIImageView = {
        
        let imgView = UIImageView()
        imgView.image = IMAGE("arrow_right")
        self.contentView.addSubview(imgView)
        
        imgView.snp.makeConstraints({ (make) in
            make.centerY.equalToSuperview()
            make.right.equalTo(-15)
        })
        return imgView
    }()
    
    lazy var iconImgView: UIImageView = {
        
        let imgView = UIImageView()
        
        imgView.contentMode = UIView.ContentMode.scaleAspectFill
        self.contentView.addSubview(imgView)
        imgView.snp.makeConstraints { (make) in
            
            make.centerY.equalToSuperview()
            make.left.equalTo(15)
        }
        return imgView
    }()
    
    lazy var headImgView: UIImageView = {
        
        let imgView = UIImageView()
        
        imgView.contentMode = UIView.ContentMode.scaleAspectFill
        self.contentView.addSubview(imgView)
        imgView.snp.makeConstraints { (make) in
            
            make.centerY.equalToSuperview()
            make.left.equalTo(15)
        }
        return imgView
    }()
    
    func showRightArrow(_ isShow:Bool) {
        
        self.arrowImgView.isHidden = !isShow
        
    }
    
    func showLine(_ topLine:Bool,_ bottomLine:Bool) {
        
        self.topLine.isHidden = !topLine
        self.bottomLine.isHidden = !bottomLine;
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.accessoryType = .none
        self.contentView.backgroundColor = .white
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //获取复用Id
    public class func identifier() -> String {
        
        let name:AnyClass! = object_getClass(self)
        
        return NSStringFromClass(name)
    }
    
    
    
    public class func cellHeightWithModel(_ model : Any) -> CGFloat {
        
        return 0.1;
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}

